.PHONY:clean

#vpath %.h /usr/local/mysql/include/		

CPP			= clang++
CPP_FLAGS 	= -Wall -g
BIN			= luoonet

INC_PATH	+= -I/usr/local/mysql/include/
LIB_PATH	+= -L/usr/local/lib/
LIB_PATH	+= -L/usr/local/mysql/lib/ 

LINK_LIB	+= -l mysqlclient
LINK_LIB	+= -l boost_thread
LINK_LIB	+= -l boost_system 

SOURCE = $(wildcard *.cc)
OBJECT = $(SOURCE:%.cc=%.o)

$(BIN):$(OBJECT)
	@echo "link " $(OBJECT)
	@$(CPP) $(CPP_FLAGS) $(LIB_PATH) $(LINK_LIB) -o $(BIN) $(OBJECT)
	@echo "build succeed!"

-include $(SOURCE:%.cc=%.d)
%.d:%.cc
	@set -e
	@rm -f $@
	@$(CPP) -MM $(CPP_FLAGS) $(INC_PATH) $< > $@.tmp
	@sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@
	@rm -f $@.tmp

$(OBJECT):%.o:%.cc
	@echo "compile "$(filter %.cc, $^)
	@$(CPP) $(CPP_FLAGS) $(INC_PATH) -c $(filter %.cc, $^) -o $@

clean:
	@rm -f $(BIN) $(OBJECT) *.d *.d.*
